package com.atguigu.eduservice.controller.front;

import com.atguigu.commonutils.R;
import com.atguigu.eduservice.entity.EduCourse;
import com.atguigu.eduservice.entity.EduTeacher;
import com.atguigu.eduservice.service.EduCourseService;
import com.atguigu.eduservice.service.EduTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/eduservice/indexfront")
//原来需要在Controller上面加上@CrossOrigin解决跨域问题，现在gateway已经处理了
@Api(description = "前台首页")
public class IndexFrontController {

    @Autowired
    private EduTeacherService eduTeacherService;

    @Autowired
    private EduCourseService eduCourseService;

    /*首页查询前8条热门课程，首页查询前4条名师*/
    @ApiOperation(value = "首页查询前8条热门课程，首页查询前4条名师")
    @PostMapping("/TeacherAndCourse")
    public R selectTeacherCourse(){
        /*查询8条热门课程*/
        List<EduCourse> courseList=eduCourseService.selectCourse();
        /*查询4条名师*/
        List<EduTeacher> teacherList=eduTeacherService.selectTeacher();
        return R.ok().data("teacherList", teacherList).data("courseList",courseList);
    }

}